﻿<!doctype html>
<html>
<!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>反结算</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/common.js"></script>
<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery.pager.js"></script>
<script type="text/javascript" src="../js/gbRst.js"></script>
<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/shop.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script>
<link href="../css/style.css" type="text/css" rel="stylesheet" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script type="text/javascript" >

$(function(){
	 $('#dtBegin').val(getToday());
	 $('#dtEnd').val(getToday());
})
function bclicks(obj){
	var $first=obj.parent("td").parent("tr").children("td:first");
	var id=$first.html();
	var name=$first.next().html();
	//$("#shopName").children("option").blur();
	getParamToshopS(id,name)
}
var pagecount = 0;
var count = 0;
var shopId="shopId";

function InitTable(pageIndex,shopId) {
	var phone=$("#phone").val().replace(/\s/gi,'');	
	var code=$("#code").val().replace(/\s/gi,'');
	var dtBegin=$("#dtBegin").val();
	var dtEnd=$("#dtEnd").val();
	var paid=$("#paid").val();
	var shopId="";
	var param='phone='+phone+'&code='+code+"&dtBegin="+dtBegin+"&dtEnd="+dtEnd+"&paidStatus=-1";
	if($("#shopIsChoosed").is(":checked")){
		var shopId=$("#shopName").val();
		
		if(shopId!=""&&shopId!=null){
			param+="&shopId="+shopId;
		}
	}

		$.ajax({
		type : "get",
		async:false,
		data :param,
		datatype : "json",
		url : "../saleBill/find/saleList/" + pageIndex + "/10",
		success : function(data) {
			var rst = JSON.parse(data);
				
					if(IsEmpty(rst)){
						art.dialog({fixed:true, lock: true,content:"查询出錯",icon:'error',ok:true});	
						return false;
						}
						if(rst.state==0){
							$("#memberList tbody tr").remove();
							var obj = DealAndShowMsg(data,false,false);
							initTable(rst);	
							if(rst.result.len > 0){
								 var shu = rst.result.len;
							 	 $("#NoResult").hide();
						 	 pagecount = Math.ceil(shu/10);
							}else{
								$("#NoResult").show();
								pagecount=0;

							}
							 	$("#sup").html("共"+rst.result.len+"条");	
							 $("#pager").pager({ pagenumber: ++pageIndex, pagecount: pagecount, buttonClickCallback: PageClick });

							
						}else if(rst.state==1){
							art.dialog({fixed:true, lock: true,content:rst.msg,icon:'error',ok:true});	
						}else{
							checkStateShowErrorMsgAndDealResult(data);
						}
					
		}	
	});
}


PageClick = function(pageclickednumber) {
    $("#pager").pager({ pagenumber: --pageclickednumber, pagecount: pagecount, buttonClickCallback: PageClick });
    $("#result").html("Clicked Page " + pageclickednumber);
	InitTable(pageclickednumber,shopId);
}

function search(){
	InitTable(0);
}

function initTable(json){
	if(json!=null && json.state==0){
		var params = new Array("shopName","billNo", "MAKEDATE","RoomNo","StandNo","Memo","memberCardNo","CustName", "mp", "shouldAmt","StaName");// "PayCash", "PayPos", "PayDepstAmt", "PayCheck", "PayPersonCard", "PayIntAmtMny", "StaName", "PaidName"
	}
	
	$("#memberList tbody").empty()
	for ( var i = 0; i < json.result.data.length; i++) {
			var htm  ="<tr>"
			for ( var j = 0; j < params.length; j++) {
			if(params[j] == "billNo")	{
			htm +="<td> <a href=\"bussBillDetil.html?no="+ _getStringOfJson(i, json, params[j]) +"&shopId="+ _getStringOfJson(i, json,"shopId" ) +" \" target = \"_blank\">"+ _getStringOfJson(i, json, params[j]) +"</a> </td>" 
				
			}else{
				htm +="<td> "+ _getStringOfJson(i, json, params[j]) +" </td>" 
			}
		
			}
			htm+="<td><input class=\"common_btn \" type=\"button\" onclick=\"tojs("+ _getStringOfJson(i, json, "ID") +")\" value=\"付款\"></td>"
			htm+= "</tr>"
	$("#memberList tbody").append(htm)
}

}

function Loadtable(json, params, tableId){
	var phArray = new Array();
	var count = 0;
	if (params != null) {
		$(params).each(function(pIndex, pData) {
			$.each(json.result.head, function(hIndex, hData) {
				if (pData == hData) {
					phArray[count++] = hIndex;
				}
			});
		});
	}
	if (json.result.data != null) {
		$.each(json.result.data, function(index, dt) {
			$("table[id='" + tableId + "']").append("<tr></tr>");
			$(phArray).each(function(phIndex, data) {
				$.each($(dt), function(dtIndex, d) {
					if (dtIndex == data) {
						$("table[id='" + tableId + "'] tr:last").append("<td>" +  (d === null||d == "null" ? " " : d) + "</td>");
					}
				});
			});
		});
		
	}
	

	
}

function  downRescouse(){
	var phone=$("#phone").val().replace(/\s/gi,'');	
	var code=$("#code").val().replace(/\s/gi,'');
	var dtBegin=$("#dtBegin").val();
	var dtEnd=$("#dtEnd").val();
	var shopId="";
	var param='phone='+phone+'&code='+code+"&dtBegin="+dtBegin+"&dtEnd="+dtEnd;
	if($("#shopIsChoosed").is(":checked")){

		
		shopId=$("#shopName").val();
		
		if(shopId!=""&&shopId!=null){
			param+="&shopId="+shopId;
		}
	}
	param+="&downType=9"
	
	window.location.href="../csvdown/down/csv/down?"+param

}

function tojs(id){
	window.location.href="sailMoney.html?saidId="+id
}

</script>
</head>

<body>
<div id="yinying"></div>
<div id="shopShow" class="hideDiv">
  <div style="float:right;margin-bottom:5px;width:20px;height:20px;line-height:20px;text-align:center;background-color:#eee;margin-bottom:5px;border:1px solid #ccc;" > <span style="cursor: pointer;font-size: 14px;" onclick="closeShopShow();" >X</span> </div>
  <div class="bottom_search">
    <div class="serWrapper"><input type="text" id="searchName" class="txt"><strong class="refresh" onclick="$('#searchName').val('')">清空</strong></div>
    <input type="button" style="width:auto;margin-left:5px;" value="查询" onclick="search2()" class="common_btn">
  </div>
  <table   id="shopList" cellpadding="4" cellspacing="0" border="1" width="100%">
    <thead>
      <tr>
        <th>店面ID</th>
        <th>店面名称</th>
        <th>电话</th>
        <th>操作</th>
      </tr>
    </thead>
  </table>
  <div id="shopPager"></div>
</div>
<!-- InstanceBeginEditable name="EditRegion3" --> 
<script type="text/javascript" src="../js/doubleDate2.0.js"></script> 
<script type="text/javascript">
$(function(){
	refreshInput($(".serWrapper"));
	$('.doubledate').kuiDate({
		className:'doubledate',
		isDisabled: "1"  // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
	});

});
</script>
<div class="container" id="container">
  <div class="container_R fr">
    <div class="place">消费记录</div>
    <div class="member_search">
      <p><span>
        <input type="checkbox" id="shopIsChoosed" style="width:auto;height:auto;border:none;">
        店面：</span>
        <select disabled="disabled" id="shopName" onclick="showShopList()" style=";height:20px;">
        </select>
        <span>起始日期：</span>
        <input type="text" readonly class="doubledate ipticon"  id="dtBegin"/>
        <span>截止时间：</span>
        <input type="text" readonly class="doubledate ipticon" id="dtEnd"/>
      </p>
      <p>
        <span>单据号：</span>
        <input type="text" id="billNo" class="absoluteTxt">
         <span>会员卡号：</span>
        <input type="text" id="code" class="absoluteTxt">
      <span>手机号：</span>
      <input type="text" id="phone" class="absoluteTxt">
      </p>
      <p>
        <span>单据号：</span>
       	<select id="paid" >
       		<option value="">所有</option>
       		<option value="-1">未付款</option>
       		<option value="2">已付款</option>
       	</select>
      <input type="button" value="查询" class="btn" onclick="search()">
      </p>
      
    </div>
    <table width="100%" class="member_list" cellpadding="0" cellspacing="1" border="0" id="memberList">
      <caption>
      <strong>消费记录列表 <span id="sup">共0条</span></strong> 
      </caption>
      <thead>
        <tr>
          <th>店面</th>
          <th>单据号</th>
          <th>消费日期</th>
          <th>房间/车牌号</th>
          <th>台号</th>
          <th>备注</th>
          <th>卡号</th>
          <th>会员名称</th>
          <th>电话</th>
          <th>消费金额</th>
		<th>状态</th>	
		<th>操作</th>	
        </tr>
      </thead>
      <tbody></tbody>
    </table>
     <div id="NoResult"  class="Nothing" style="text-align:center;display: none;">无符合条件的数据！</div>
    <div id="pager" style="float: right;"></div>
  </div>
  <div class="fc"></div>
</div>
<!-- InstanceEndEditable --> 
<script type="text/javascript" src="../js/header.js"></script> 
<script type="text/javascript" src="../js/left.js"></script> 
<script type="text/javascript" src="../js/footer.js"></script> 
<script type="text/javascript">
clearThis("absoluteTxt");
showTab(7,4);
</script>
</body>
<!-- InstanceEnd -->
</html>
